#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "skiplist.h"

#define TESTNUM 10000000
extern skiplist list;

int main()
{
	srand(time(0));
	clock_t begin,end;
	init();
	int i;
	begin = clock();
	for(i=0; i<TESTNUM; i++){
		insert((rand()*rand())%TESTNUM+rand());
	}
	end = clock();
	printf("time:%f\n",(end-begin)/1000.0);
	//printlist();

	
	while(1){
		char cmd[10];
		int data;
		scanf("%s",cmd);
		if(!strcmp(cmd,"insert")||!strcmp(cmd,"i")){
			scanf("%d",&data);
			begin = clock();
			insert(data);
		}else if(!strcmp(cmd,"remove")||!strcmp(cmd,"r")){
			scanf("%d",&data);
			begin = clock();
			remove(data);
		}else if(!strcmp(cmd,"find")||!strcmp(cmd,"f")){
			scanf("%d",&data);
			begin = clock();
			if(find(data)){
				printf("success\n");
			}else{
				printf("failed\n");
			}
		}else if(!strcmp(cmd,"print")||!strcmp(cmd,"p")){
			printlist();
		}else if(!strcmp(cmd,"quit")||!strcmp(cmd,"q")){
			break;
		}else if(!strcmp(cmd,"pl"))	{
			for(i=list.levelnum; i>=0; i--){
				printf("level %d: %d\n",i,list.num[i]);
			}
		}else if(!strcmp(cmd,"p-o-l")){
			int level;
			scanf("%d",&level);
			printOneLevel(level);
		}else
			printf("command %s is not valid!\n",cmd);
	end = clock();
	printf("time:%f\n",(end-begin)/1000.0);
	}
	return 0;
}